{% extends 'TopxiaWebBundle:Group:layout.html.twig' %}
{% set script_controller = 'group/group' %}
{% block title %}{{groupinfo.title}}{{'小组'|trans}} {{ parent() }}{% endblock %}
{% block keywords %}{{groupinfo.title}}{% endblock %}
{% block description %}{{groupAbout|default('')|plain_text(100)}}{% endblock %}
{% set groupNav = 'index' %}

{% block group_main %}
  <div class="panel panel-default">
    <div class="panel-heading"><h3 class="panel-title">{{'小组介绍'|trans}}</h3></div>
    <div class="panel-body">
      {% if paginator.currentPage == paginator.firstPage %}
        <div class="well editor-text">
          {% if groupinfo.about%} {{groupinfo.about|raw}} {% else %} {{'暂无简介'|trans}} {% endif %}
        </div>
      {% endif %}
    </div>
  </div>
  <div class="panel panel-default">
    <div class="panel-body">
      <ul class="nav nav-tabs">
        <li {% if groupNav=="index" %}class="active"{% endif %}><a href="{{path('group_show',{id:groupinfo.id})}}">{{'小组首页'|trans}}</a></li>
        <li {% if groupNav=="member" %}class="active"{% endif %}><a href="{{path('group_member',{id:groupinfo.id})}}">{{'小组成员'|trans}}</a></li>
        {% if is_groupmember==2 or is_granted('ROLE_ADMIN') or is_groupmember==3%}
          <li {% if groupNav=="setting" %}class="active" {% endif %}><a  href="{{path('group_set',{id:groupinfo.id})}}">{{'小组设置'|trans}}</a></li>
        {% endif %}
      </ul>

      {{ web_macro.flash_messages() }}
      <div class="nav-filter clearfix mbl">

      <ul class="nav nav-pills nav-pills-sm">

        <li{% if condition.type == 'all' %} class="active"{% endif %}><a class="js-nav" data-target="#thread-pane" href="{{path('group_show',{id:id,num:condition.num,sort:condition.sort,isElite:0})}}">{{'全部'|trans}}</a></li>

        <li{% if condition.type == 'elite' %} class="active"{% endif %}><a class="js-nav" data-target="#thread-pane" href="{{path('group_show',{id:id,type:'elite',num:condition.num,sort:condition.sort})}}">{{'精华'|trans}}</a></li>

        {% if is_feature_enabled('group_reward') %}
        <li{% if condition.type == 'reward' %} class="active"{% endif %}><a class="js-nav" data-target="#thread-pane" href="{{path('group_show',{id:id,type:'reward',num:condition.num,sort:condition.sort})}}">{{'悬赏'|trans}}</a></li>
        {% endif %}

        <li class="dropdown">
          <a class="dropdown-toggle" data-toggle="dropdown" href="#">
            <span class="text-muted">{{'排序：'|trans}}</span>
            {% if condition.sort == 'byLastPostTime' %}
              {{'最后回复'|trans}}
            {% elseif condition.sort == 'byCreatedTime' %}
              {{'最新发帖'|trans}}
            {% elseif condition.sort == 'byPostNum' %}
              {{'回复数'|trans}}
            {% endif %}
            <span class="caret"></span>
          </a>
          <ul class="dropdown-menu">
            <li class="{% if condition.sort == 'byCreatedTime' %}active{% endif %}"><a class="js-nav" href="{{path('group_show',{id:id,isElite:condition.type,num:condition.num,sort:'byCreatedTime'})}}">{{'最新发帖'|trans}}</a></li>
            <li class="{% if condition.sort == 'byLastPostTime' %}active{% endif %}"><a class="js-nav" href="{{path('group_show',{id:id,isElite:condition.type,num:condition.num,sort:'byLastPostTime'})}}">{{'最后回复'|trans}}</a></li>
            <li class="{% if condition.sort == 'byPostNum' %}active{% endif %}"><a class="js-nav" href="{{path('group_show',{id:id,isElite:condition.type,num:condition.num,sort:'byPostNum'})}}">{{'回复数'|trans}}</a></li>
          </ul>
        </li>
      </ul>


      </div>

      {% include 'TopxiaWebBundle:Group:groups-threads-ul.html.twig' with {users:owner} %}

      {{ web_macro.paginator(paginator) }}
    </div>
  </div>
{% endblock %}

{% block group_side %}
  {% if is_groupmember != 0 %}
    <div class="mbm"><a href="{{path('group_thread_add',{id:groupinfo.id})}}" class="btn btn-success btn-xlg btn-block" role="button"><i class="es-icon es-icon-comment mrs text-xlg"></i>{{'发表话题'|trans}}</a>
    </div>
  {% endif %}
  <form class="mbl" action="{{path('group_search',{id:groupinfo.id})}}" method="get">
  <div class="search-with-btn">
    <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">
    <input type="text" class="form-control" placeholder="{{'组内搜索'|trans}}" name="keyWord">
    <button class="btn btn-default" type="submit"><span class="glyphicon glyphicon-search"></span></button>
  </div>
  </form>
  {% if is_groupmember in [1, 2, 3] %}
    <div class="panel panel-default">
      <div class="panel-body group-user-info">
        <div class="media group-item">
          <div class="media-left">
            {{ web_macro.user_avatar(user, '' ,'avatar-md') }}
          </div>
          <div class="media-body">
            <p>{{ web_macro.user_link(user , '') }}

              {% if is_groupmember==1%}
              <span class="label label-primary">{{'组员'|trans}}</span>
              {% endif %}

              {% if is_groupmember==2%}
              <span class="label label-primary">{{'组长'|trans}}</span>
              {% endif %}

              {% if is_groupmember==3%}
              <span class="label label-primary">{{'副组长'|trans}}</span>
              {% endif %}
            </p>
            <a href="{{ path ('group_member_center') }}" class="btn btn-default btn-sm" role="button">{{'我的小组'|trans}}</a>
          </div>
          <hr>
           <p class="group-message clearfix">
              <span><strong>{{userIsGroupMember.threadNum}}</strong>{{'话题'|trans}}</span>
              <span><strong>{{userIsGroupMember.postNum}}</strong>{{'回复'|trans}}</span>
            </p>
        </div>
      </div>
    </div>
  {% endif %}
  <div class="panel panel-default">
    <div class="panel-heading"><h3 class="panel-title">{{'小组组长'|trans}}</h3></div>
    <div class="panel-body">
      <div class="media group-item">
        <div class="media-left">
          {{ web_macro.user_avatar(groupOwner, '') }}
        </div>
        <div class="media-body">
          <div><a class="gray-darker" href="{{path('user_show',{id:groupOwner.id})}}" title="{{groupOwner.nickname}}">{{groupOwner.nickname}}</a></div>
          <span class="text-sm gray-medium">{{groupOwner.title|default("无"|trans)}}</span>
        </div>
      </div>
    </div>
  </div>


  <div class="panel panel-default">
    <div class="panel-heading"><h3 class="panel-title">{{'新加组员'|trans}}</h3></div>
    <div class="panel-body">
      {% if recentlyJoinMember %}
        <ul class="user-avatar-list clearfix">
          {% for member in recentlyJoinMember %}
            <li>
              {{ web_macro.user_avatar(members[member.userId] ,'', 'avatar-sm') }}
            </li>
          {% endfor %}
        </ul>
      {% else %}
        <div class="empty">{{'还没有小组成员！'|trans}}</div>
      {% endif %}
    </div>
  </div>

  <div class="panel panel-default">
    <div class="panel-heading"><h3 class="panel-title">{{'热门小组'|trans}}</h3></div>
    <div class="panel-body">
      <div class="media-group-list">
      {% set hotGroups = data('HotGroup',{'count':3}) %}
      {% for group in hotGroups %}
        <div class="media media-group">
          <div class="media-left prm">
            <a href="{{path('group_show',{id:group.id})}}" title="{{group.title}}">
              <img src="{{filepath(group.logo, 'group.png')}}" alt="{{group.title}}" class="avatar-square-md">
            </a>
          </div>
          <div class="media-body">
            <div class="title">
              <a class="gray-darker" href="{{ path('group_show',{id:group.id}) }}" title="{{group.title}}">
                {{group.title}}
              </a>
            </div>
            <div class="metas">
              <span><i class="es-icon es-icon-people"></i>{{group.memberNum}}</span>
              <span><i class="es-icon es-icon-textsms"></i>{{group.threadNum}}</span>
            </div>
          </div>
        </div>
      {% else %}
        <div class="empty">{{'暂无小组信息！'|trans}}</div>
      {% endfor %}
      </div>

    </div>
  </div>

{% endblock %}